package com.company.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.base.common.service.CrudService;
import com.company.dao.ProjectWbsMapper;
import com.company.model.CompanyProject;
import com.company.model.ProjectWbs;
import com.company.service.ProjectWbsService;

@Service
public class ProjectWbsServiceImpl extends
		CrudService<ProjectWbsMapper, ProjectWbs> implements ProjectWbsService {
	String[] wbsArray = { "项目启动", "初级设计", "详细设计", "设计验证", "试产验证", "推向市场",
			"量产后改进" };

	public boolean saveProjectWbs(String projectId) throws Exception {
		for (String wbs : wbsArray) {
			ProjectWbs projectWbs = new ProjectWbs();
			projectWbs.setProjectId(projectId);
			projectWbs.setWbsName(wbs);
			projectWbs.setDelFlag("0");
			this.saveOrUpdate(projectWbs);
		}
		return true;
	}
	
	public List<ProjectWbs> findProjectWbsByProjectId(String projectId)  throws Exception {
		Map<String, String> params = new HashMap<String, String>();
		params.put("projectId", projectId);
		String sql = "SELECT * FROM project_wbs t where t.project_id = #{projectId} ";
		List<ProjectWbs> list = this.getList(sql, ProjectWbs.class,
				params);
		return list;
	}
	
}
